package com.yunhai.device.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yunhai.common.dto.PaginationVo;
import com.yunhai.common.dto.Ret;
import com.yunhai.device.service.DeviceLockNetworkService;
import com.yunhai.model.entity.dms.DmsDeviceLockNetworkEntity;
import com.yunhai.model.vo.dms.DmsDeviceLockNetworkQuery;
import com.yunhai.model.vo.dms.DmsDeviceLockNetworkVo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/deviceLockNetwork")
public class DeviceLockNetworkController {

	@Resource
	private DeviceLockNetworkService deviceLockNetworkService;


	/**
	 * 获取 DeviceLockNetwork 分页列表
	 */
	@GetMapping("/pagination")
	public Ret getDeviceLockNetworkPagination(PaginationVo paginationVo, DmsDeviceLockNetworkQuery dmsDeviceLockNetworkQuery ) throws Exception {
		IPage page = deviceLockNetworkService.getDeviceLockNetworkPagination(paginationVo, dmsDeviceLockNetworkQuery );
		return Ret.toPage(page);
	}


	/**
	 * 获取 DeviceLockNetwork 所有数据
	 */
	@GetMapping("/allList")
	public Ret getDeviceLockNetworkAllList( DmsDeviceLockNetworkQuery dmsDeviceLockNetworkQuery ) throws Exception {
		List<DmsDeviceLockNetworkEntity> list = deviceLockNetworkService.getDeviceLockNetworkAllList( dmsDeviceLockNetworkQuery );
		return Ret.ok(list);
	}


	/**
	 * 获取 DeviceLockNetwork 详情
	 */
	@GetMapping("/{id}")
	public Ret getDeviceLockNetworkDetailById(@PathVariable Long id) throws Exception {

	    DmsDeviceLockNetworkEntity dmsDeviceLockNetworkEntity = deviceLockNetworkService.getDeviceLockNetworkDetail(id);
		return Ret.ok(dmsDeviceLockNetworkEntity);
	}


	/**
	 * 新增 DeviceLockNetwork
	 * */
	@PostMapping("")
	public Ret addDeviceLockNetwork(@RequestBody DmsDeviceLockNetworkVo dmsDeviceLockNetworkVo) throws Exception {

		deviceLockNetworkService.addDeviceLockNetwork(dmsDeviceLockNetworkVo);
		return Ret.ok();
	}


	/**
	 * 更新 DeviceLockNetwork
	 * */
	@PutMapping("")
	public Ret updateDeviceLockNetwork(@RequestBody DmsDeviceLockNetworkVo dmsDeviceLockNetworkVo) throws Exception {

		deviceLockNetworkService.updateDeviceLockNetwork(dmsDeviceLockNetworkVo);
		return Ret.ok();
	}


	/**
	 * 删除 DeviceLockNetwork
	 * */
	@PostMapping("/batchRemove")
	public Ret batchRemoveDeviceLockNetwork( @RequestBody List<Long> ids ) throws Exception {

	    deviceLockNetworkService.batchRemoveDeviceLockNetwork(ids);
		return Ret.ok();
	}
}
